package demo.producer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@EnableBinding(OmsSource.class)
public class OmsProducer {

    @Resource
    private OmsSource omsSource;

    private Logger logger = LoggerFactory.getLogger(OmsProducer.class);

    public void outputChannel1(String msg) {
        boolean successful = omsSource.outputChannel1().send(MessageBuilder.withPayload(msg).build());
        logger.info("给发送OMS的Channel-1消息 {}", successful ? "成功" : "失败");
    }

    public void outputChannel2(String msg) {
        boolean successful = omsSource.outputChannel1().send(MessageBuilder.withPayload(msg).build());
        logger.info("给发送OMS的Channel-2消息 {}", successful ? "成功" : "失败");
    }

}
